<!--
 * @Author: 敬华丰 2637844016@qq.com
 * @Date: 2023-07-17 17:39:33
 * @LastEditors: 敬华丰 2637844016@qq.com
 * @LastEditTime: 2023-07-18 10:53:09
 * @FilePath: \出口卖家端\src\views\Credit\components\BankItem.vue
 * 状态(0-待补充资料,1-待平台审核,2-待银行审核,3-待平台确认授信金额,4-已完成)
-->
<template>
  <div class="bank">
    <div class="bank-header">
      <div class="bank-logo">
        <img src="@/assets/img/jiansheyinhang-logo.png" />
      </div>
      <div class="bank-name">{{ item.bankName }}</div>
    </div>
    <div class="bank-body">
      <div class="body-title">
        <span v-if="item.status === 4"
          >可用额度（元） 授信利率：{{ item.rate }}%</span
        >
        <span v-else>授信利率区间</span>
      </div>
      <div class="available-credit">
        <span v-if="item.status === 4">{{
          filters.thousands(item.currentAmount)
        }}</span>
        <span v-else>{{ item.creditRateMin }}%~{{ item.creditRateMax }}%</span>
      </div>
      <div class="flex-y-center">
        <div class="flex-1">
          <div class="body-title">
            <span>授信总额度（元）</span>
          </div>
          <div class="available-credit other-quota">
            <span v-if="item.status === 4">{{
              filters.thousands(item.sumAmount)
            }}</span>
            <span v-else>- -</span>
          </div>
        </div>
        <div class="flex-1">
          <div class="body-title">
            <span>已用额度（元）</span>
          </div>
          <div class="available-credit other-quota">
            <span v-if="item.status === 4">{{
              filters.thousands(item.useAmount)
            }}</span>
            <span v-else>- -</span>
          </div>
        </div>
      </div>
      <!-- 待审核 -->
      <div class="status-img" v-if="[1, 2].includes(item.status)">
        <img src="@/assets/img/sh_shenhezhong.png" />
      </div>
    </div>
    <div class="bank-footer">
      <div class="flex-y-center">
        <div class="footer-time">
          <img src="@/assets/img/credit-time-bank.png" />
        </div>
        <div>授信到期时间： {{ filters.dateYMDFormat(item.timeExpiry) || '- -'}}</div>
      </div>
      <!-- 未审批 -->
      <div @click="handleCreditApply(item)" class="footer-button pointer" v-if="item.status === null">申请授信</div>
      <!-- 待审核 -->
      <div class="footer-button pointer" v-else-if="item.status === 0">
        补充资料
      </div>
      <!-- 已完成 -->
      <div class="footer-button pointer" v-else-if="item.status === 4" 
      @click="handleLoanStatement(item)">借款账单</div>
    </div>
  </div>
</template> 
<script setup>
import { ref, computed } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({
  modelValue: {
    type: Object,
    default: {},
  },
});
const item = computed({
  get: () => {
    return props.modelValue;
  },
});
const handleLoanStatement = (item)=>{
  router.push({
    path:'/Loan',
    query:{
      key:0,
      bankId:item.id
    }
  })
}
const handleCreditApply =(item)=>{
  router.push({
    path:'/Credit/Details',
    query:{
      bankId:item.id,
      bankName:item.bankName,
      creditId:item.creditId
    }
  })
}
</script>
<style lang="less" scoped>
.bank {
  background: #f7f8fa;
  box-shadow: 0px 4px 6px 0px rgba(58, 54, 51, 0.16);
  border-radius: 12px;
  width: 345px;
  .bank-header {
    height: 48px;
    border-radius: 12px 12px 0px 0px;
    border-bottom: 1px solid #f2f2f2;
    display: flex;
    align-items: center;
    .bank-logo {
      width: 24px;
      height: 24px;
      margin-right: 8px;
      margin-left: 20px;
    }
    .bank-name {
      color: #202020;
      font-size: 16px;
    }
  }
  .bank-body {
    height: 125px;
    margin-left: 20px;
    margin-top: 12px;
    margin-bottom: 12px;
    position: relative;
    .body-title {
      font-size: 12px;
      color: #595959;
    }
    .available-credit {
      margin-top: 5px;
      font-size: 22px;
      font-weight: bold;
      color: #ee5b5b;
      margin-bottom: 12px;
    }
    .other-quota {
      color: #202020;
    }
    .status-img {
      position: absolute;
      top: 0;
      right: 32px;
      width: 54px;
      height: 40px;
    }
  }
  .bank-footer {
    background: url("@/assets/img/credit-bank-bootom.png") no-repeat;
    background-size: 100% 100%;
    height: 40px;
    border-radius: 0px 0px 12px 12px;
    color: #f4ce82;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 15px;
    padding-left: 20px;
    .footer-time {
      width: 16px;
      height: 16px;
      padding-right: 4px;
    }

    .footer-button {
      color: #6e3c08;
      padding: 4px 12px;
      border-radius: 13px;
      font-size: 12px;
      background: linear-gradient(90deg, #fae9b8 0%, #f4ce82 100%);
    }
  }
}
</style>